//
//  HomeViewController.swift
//  CustomSwiftProject
//
//  Created by 岚海网络 on 2019/4/8.
//  Copyright © 2019 ljm. All rights reserved.
//

import UIKit

class HomeViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
    
    let identifier:String = "HomeCell"
    
    var tableview = UITableView()
    
    var dataArray = [HomeModel]()
    
    

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        createWithUI()
    }
    
    
    func createWithUI() {
        title = "首页"
        view.backgroundColor = .white
        
        
        tableview = UITableView.init()
        tableview.backgroundColor = .white
        tableview.delegate = self
        tableview.dataSource = self
        tableview.separatorStyle = .none
        tableview.rowHeight = 300
        tableview.register(HomeCell.classForCoder(), forCellReuseIdentifier: identifier)
        view.addSubview(tableview)
        tableview.snp.makeConstraints{
            $0.top.left.bottom.right.equalTo(view)
        }
        
        
        for _ in 0...10{
            let model = HomeModel()
            model.imageV = UIImage.init(named: "property_food")!
            model.title = "糖醋小排骨"
            model.icon = UIImage.init(named: "avater")!
            model.name = "厨师许庭淞"
            model.content = "糖醋小排骨拉伸过几年给过你倒计时啦看风景刚卡死了都给弄女孩覅设计稿放假哦第三次你赶紧发阿斯加德过来撒结果的困了就睡光靠手发附近空了撒娇过来看时间过得是考虑到九分裤介绍个"
            dataArray.append(model)
        }
        
        
    }
    
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataArray.count
    }
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell:HomeCell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) as! HomeCell
        cell.model = dataArray[indexPath.row]
        return cell
    }
    


    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
